package dyyx.server;

import java.io.IOException;
import java.io.OutputStream;
import java.util.Date;

import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.Headers;

import com.sun.net.httpserver.HttpHandler;

public class DefaultHandler implements HttpHandler {
	
	
    public void handle(HttpExchange t) throws IOException {
    	
    	
      Headers responseHeaders = t.getResponseHeaders();
      // text/plain
      responseHeaders.set("Content-Type", "text/html");
    	
      String msg = "hello,default,simple http server,"+new Date();
      byte [] response = msg.getBytes();
      t.sendResponseHeaders(200, response.length);
      OutputStream os = t.getResponseBody();
      os.write(response);
      os.close();
    }
  }